#include <iostream>
#include <fcntl.h>
#include <unistd.h>

int main(){
    int fd=open("./namedp",O_WRONLY);
    if(fd<0){
        perror("write named pipe error");
        exit(6);
    }
    while(1){
        char buf[1024];
        std::cout<<"client >>>";
        fflush(stdout);
        ssize_t n=read(0,buf,sizeof(buf)-1);
        if(n>0){
            buf[n]=0;
            write(fd,buf,sizeof(buf));
        }else{
            continue;
        }
    }
    close(fd);
    return 0;
}